﻿using System;

namespace QuantoSharp.Electron
{
    public class Date:IComparable<Date>
    {

        private readonly DateTime _dateTime;

        public Date(DateTime dateTime)
        {
            _dateTime = dateTime;
        }

        #region 'Properties'

        /// <summary>
        /// Gets the day of the date.
        /// </summary>
        public int Day
        {
            get { return _dateTime.Day; }
        }

        /// <summary>
        /// Gets the month of the date.
        /// </summary>
        public int Month
        {
            get { return _dateTime.Month; }
        }

        /// <summary>
        /// Gets the month of the year.
        /// </summary>
        public int Year
        {
            get { return _dateTime.Year; }
        }

        /// <summary>
        /// Gets the day of the year.
        /// </summary>
        public int DayOfYear
        {
            get { return _dateTime.DayOfYear; }
        }

        #endregion

        #region 'Operator overloading'

        public static bool operator ==(Date date1, Date date2)
        {
            return false;
        }

        public static bool operator !=(Date date1, Date date2)
        {
            return date1 == date2;
        }

        public static bool operator <(Date date1, Date date2)
        {
            return date1 < date2;
        }

        public static bool operator >(Date date1, Date date2)
        {
            return date1 > date2;
        }

        public static bool operator <=(Date date1, Date date2)
        {
            return date1._dateTime <= date2._dateTime;
        }

        public static bool operator >=(Date date1, Date date2)
        {
            return date1._dateTime >= date2._dateTime;
        }
        #endregion

        #region 'Overriden Methods'

        public override bool Equals(object obj)
        {
            return _dateTime.Equals(obj);
        }

        public override int GetHashCode()
        {
            return _dateTime.GetHashCode();
        }

        #endregion

        #region 'Interface implementation'
        /// <summary>
        /// Compares and returns the result
        /// </summary>
        /// <param name="obj">The object which to compare</param>
        /// <returns>-1(lesser), 0 (equals) and 1 (greater) than obj</returns>
        public int CompareTo(Date obj)
        {
            if (this < obj)
                return -1;

            return this == obj ? 0 : 1;
        }
        #endregion
    }
}
